package org.soenea.doitall.application.dispatcher;

import java.io.IOException;
import javax.servlet.ServletException;

import org.soenea.doitall.domain.command.CreateGroupCommand;
import org.soenea.doitall.domain.command.exception.CurrentUserInGroupException;
import org.soenea.doitall.domain.command.exception.UserModifiedException;
import org.dsrg.soenea.domain.command.CommandException;

public class CreateGroup extends Dispatcher {
	@Override
	public void execute() throws ServletException, IOException {
		try {
			new CreateGroupCommand(this.myHelper).execute();
			relativeRedirect("viewgroup");
		} catch (UserModifiedException e) {
			forward("/WEB-INF/jsp/LoginTV.jsp?error=usermodified");
		} catch (CurrentUserInGroupException e) {
			forward("/WEB-INF/jsp/LoginTV.jsp?error=useringroup");
		} catch (final CommandException e) {
			throw new ServletException(e);
		}
	}
}
